<?php
class Order_Model_Waitshipment
{

	private $_table;
	//Initalizing Db Table  
	public function __construct(){
		$this->_table = new Order_Model_DbTable_Order();
	}
	
	public function getAdapter(){
		return $this->_table->getAdapter(); 
	}
	
	
	public function groupByShipMethod($condition=array(),$orderby=array()){
		$select = $this->_table->getAdapter()->select();
		$table = $this->_table->info('name');
		$select->from($table,"shipping_method,count(*) count");
		if(isset($condition["orders_status"]) && $condition["orders_status"]!=''){
			$select->where(" orders_status = ?",$condition["orders_status"]);
		}
		if(isset($condition["process_status"]) && $condition["process_status"]!=''){
			$select->where(" process_status = ?",$condition["process_status"]);
		}
		
		$select->where(" ship_date>=?",date("Y-m-d")." 00:00:00");
		$select->where(" ship_date<=?",date("Y-m-d")." 23:59:59");
		
		$select->group("shipping_method");
		$select->order($orderby);
		$sql=$select->__toString();
		//print_r($sql);exit;
		$result =  $this->_table->getAdapter()->fetchAll($sql);

		return $result;
		
	}
	
	
}